package com.tpyg.wallet.account.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tpyg.wallet.account.entity.ChatUser;
import com.tpyg.wallet.account.service.ChatUserService;
import com.tpyg.wallet.common.Const;
import com.tpyg.wallet.frame.utils.ResponseUtils;

@Controller
public class ChatUserController {

	@Resource
	private ChatUserService chatUserService;
	
	/**
	 * 查看账号信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/user/getByid" ,method=RequestMethod.POST)
	@ResponseBody
	public Object getByid(@RequestParam Long id) {
		try {
			ChatUser user = chatUserService.selectByPrimaryKey(id);
			return ResponseUtils.buildSuccessRes(user);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseUtils.buildErrorRes(Const.GENERAL_ERROR, e.getMessage());
		}
	}
	
	
	
	/**
	 * 查看账号信息
	 * @param id
	 * @return
	 */
	@RequestMapping(value="/user/getByUsername" ,method=RequestMethod.GET)
	@ResponseBody
	public Object getByUsername(@RequestParam String username) {
		try {
			ChatUser user = chatUserService.selectByUsername(username);
			return ResponseUtils.buildSuccessRes(user);
		} catch (Exception e) {
			e.printStackTrace();
			return ResponseUtils.buildErrorRes(Const.GENERAL_ERROR, e.getMessage());
		}
	}
}
